/**
 * 
 */
package fb.chatter.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

/**
 * @author hoannguyen
 * 
 */
public final class ExceptionUtils {

	/**
	 * Logging file name
	 */
	private static final String fileName = "D:\\fb-exception-log.log";
	
	/**
	 * To log the given exception to both file and console
	 * @param e
	 */
	public static void log(Exception e) {

		try {
			// Create File PrintStream
			FileOutputStream fos = new FileOutputStream(new File(fileName));  
			PrintStream ps = new PrintStream(fos);  
			
			// Print the Stack trace to file
			e.printStackTrace(ps);

			// Print the Stack trace to console
			e.printStackTrace();
			
		}catch(FileNotFoundException e1){
			e.printStackTrace();
		}
	}
}
